package com.shycloud.mido.member.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.shycloud.mido.common.core.exception.BusinessException;
import com.shycloud.mido.member.api.entity.AtvMainOffline;
import com.shycloud.mido.member.api.vo.AtvMainOfflineMemberDetailVO;
import com.shycloud.mido.member.mapper.AtvMainOfflineMapper;
import lombok.AllArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.shycloud.mido.member.api.entity.AtvMainOfflineMemberDetail;
import com.shycloud.mido.member.mapper.AtvMainOfflineMemberDetailMapper;
import com.shycloud.mido.member.service.AtvMainOfflineMemberDetailService;

@Service
@AllArgsConstructor
public class AtvMainOfflineMemberDetailServiceImpl extends
		ServiceImpl<AtvMainOfflineMemberDetailMapper, AtvMainOfflineMemberDetail> implements AtvMainOfflineMemberDetailService {

	/** 活动主表业务 mapper */
	private final AtvMainOfflineMapper atvMainOfflineMapper;

	@Override
	public List<AtvMainOfflineMemberDetailVO> getShareList(AtvMainOfflineMemberDetail atvMainOfflineMemberDetail, String memberId) {

		//判断是否有权限查询分享列表
		AtvMainOffline atvMainOffline = atvMainOfflineMapper.selectById(atvMainOfflineMemberDetail.getMainOfflineId());

		if (atvMainOffline != null) {
			if (!StringUtils.equals(atvMainOffline.getFromMemberId(), memberId)) {
				throw new BusinessException("您不是本房间的发起者无法查看详情");
			}
		}

		return baseMapper.getShareList(atvMainOfflineMemberDetail);

	}
}
